sum = 0
for i in range (1, 2020):
    st = str(i)
    if ("2" in st) or ("0" in st) or ("1" in st) or ("9" in st):
        sum += (i * i)
print(sum)
